package com.ruoyi.web.controller.warehouse;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WarehouseComeDetails;
import com.ruoyi.system.service.IWarehouseComeDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库明细表Controller
 * 
 * @author ruoyi
 * @date 2023-05-26
 */
@RestController
@RequestMapping("/system/details")
public class WarehouseComeDetailsController extends BaseController
{
    @Autowired
    private IWarehouseComeDetailsService warehouseComeDetailsService;

    /**
     * 查询入库明细表列表
     */
    @PreAuthorize("@ss.hasPermi('system:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseComeDetails warehouseComeDetails)
    {
        startPage();
        List<WarehouseComeDetails> list = warehouseComeDetailsService.selectWarehouseComeDetailsList(warehouseComeDetails);
        return getDataTable(list);
    }

    /**
     * 导出入库明细表列表
     */
    @PreAuthorize("@ss.hasPermi('system:details:export')")
    @Log(title = "入库明细表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseComeDetails warehouseComeDetails)
    {
        List<WarehouseComeDetails> list = warehouseComeDetailsService.selectWarehouseComeDetailsList(warehouseComeDetails);
        ExcelUtil<WarehouseComeDetails> util = new ExcelUtil<WarehouseComeDetails>(WarehouseComeDetails.class);
        util.exportExcel(response, list, "入库明细表数据");
    }

    /**
     * 获取入库明细表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:details:query')")
    @GetMapping(value = "/{warehouseComeDetailsId}")
    public AjaxResult getInfo(@PathVariable("warehouseComeDetailsId") String warehouseComeDetailsId)
    {
        return success(warehouseComeDetailsService.selectWarehouseComeDetailsByWarehouseComeDetailsId(warehouseComeDetailsId));
    }

    /**
     * 新增入库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:add')")
    @Log(title = "入库明细表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehouseComeDetails warehouseComeDetails)
    {
        return toAjax(warehouseComeDetailsService.insertWarehouseComeDetails(warehouseComeDetails));
    }

    /**
     * 修改入库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:edit')")
    @Log(title = "入库明细表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehouseComeDetails warehouseComeDetails)
    {
        return toAjax(warehouseComeDetailsService.updateWarehouseComeDetails(warehouseComeDetails));
    }

    /**
     * 删除入库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:remove')")
    @Log(title = "入库明细表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseComeDetailsIds}")
    public AjaxResult remove(@PathVariable String[] warehouseComeDetailsIds)
    {
        return toAjax(warehouseComeDetailsService.deleteWarehouseComeDetailsByWarehouseComeDetailsIds(warehouseComeDetailsIds));
    }
}
